# -- coding: utf-8 --
# @time : 2023/6/28
# @author : 周梦泽
# @file : calculate_date.py
# @software: pycharm
# 计算日期
from datetime import timedelta, datetime


def count_day(start_date: [datetime, str, float], how_day):
    """
    计算多少天前或后的日期
    :return:
    """
    if isinstance(start_date, datetime):
        start_date = start_date.date()
    if isinstance(start_date, float):
        start_date = datetime.fromtimestamp(start_date).date()
    if isinstance(start_date, str):
        start_date = datetime.strptime(start_date, "%Y-%m-%d").date()
    future_date = start_date + timedelta(days=how_day + 1)
    return future_date


if __name__ == '__main__':
    print(count_day("2021-06-28", 30))
